var qqcs;

$(function () {

    var resultdata = $("#result").val();
    $("#xs_div").height($(window).height());
    //初始化图表
    if(resultdata){
        initTb(JSON.parse(resultdata));
    }

});

//初始化图表
function initTb(result) {
    require.config({
        paths: {
            echarts: echarts2_dist_url
        }
    });

    require(
        [
            'echarts',
            'echarts/chart/pie'
        ],
        function (ec) {
            var myChart = ec.init(document.getElementById('xs_div'));
            window.onresize = function () {
                if (myChart) {
                    myChart.resize();
                }
            };
            option = {
                tooltip: {
                    trigger: 'item',
                    formatter: "{b}:<br/>共计{c}户 <br/>占比{d}%"
                },
                calculable: true,
                series: [
                    {
                        name: '企业信用评定情况',
                        type: 'pie',
                        radius: '55%',
                        center: ['50%', '50%'],
                        data: [
                            {value: result["A_HS"],  name: '正常户企业'},
                            {value: result["B_HS"], name: '正常户个体'},
                            {value: result["C_HS"], name: '正常非企业单位'},
                            {value: result["D_HS"], name: '非正常户企业'},
                            {value: result["M_HS"],name: '非正常户个体'}
                         ]
                    }
                ]
            };
            myChart.setOption(option);
        }
    );
}